package com.ctrip.ec.biz.dao.brand;

import ch.qos.logback.classic.util.LoggerNameUtil;
import com.ctrip.ec.dal.DaoBase;
import com.ctrip.ec.biz.entity.brand.BrandEntity;
import com.ctrip.ec.dal.DbAccess;
import com.ctrip.ec.dal.IdConvert;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

@Service
public class BrandDao extends DaoBase<BrandEntity> {
    public BrandDao() {
        super(BrandEntity.class);
    }

    public BrandDao(DbAccess db) {
        super(BrandEntity.class, db);
    }

    public List<Long> getImageIds(List<Long> ids) throws SQLException {

        String strIds = IdConvert.join(ids);

        String sql = " select logo_image_id from e_brand where id in (" + strIds + ")" +
                " union " +
                " select cover_image_id from e_brand where id in (" + strIds + ")" +
                " union " +
                " select banner_image_id from e_brand where id in (" + strIds + ")";
        List<Long> imageIds = this.db.query(Long.class,sql);
        return imageIds;
    }
}
